<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>地狱回调</h1>
<hr>
<script>
    //喝茶
    function drinkTea() {
        return new Promise(function (resolve) {
            setTimeout(() => resolve('开始喝茶了...'), 2000);
        })
    }

    //洗澡
    function bath() {
        return new Promise(function (resolve) {
            setTimeout(() => resolve('开始洗澡了....'), 3000);
        })

    }

    //吃火锅
    function eatHotPot() {
        return new Promise(function (resolve) {
            setTimeout(() => resolve('开始吃火锅了...'), 5000);
        })
    }


    async function haveGoodTime() {
        //直接获得resolve返回的异步数据。
        let hotPot = await eatHotPot();
        console.log(hotPot);
        let tea = await drinkTea();
        console.log(tea);
        let myBath = await bath();
        console.log(myBath);
    }


    /*
    let promise = eatHotPot();
    promise.then((resp) => {
        console.log(resp);
        return drinkTea();
    }).then((resp)=>{
        console.log(resp);
        return bath();
    }).then((resp)=>{
        console.log(resp);
    })*/

    haveGoodTime();
</script>
</body>
</html>